package com.xinye.opengl

import android.app.Activity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        if(isSupportGL20(applicationContext)){
            Log.i("wangheng","support OpenGL ES 20")
        }

        if(!isEmulator()){
            Log.i("wangheng","device is real device")
        }

        if(!isSupportGL20(applicationContext)){
            return
        }

        surfaceView.setRenderer(GLRenderer())

        window.setBackgroundDrawable(null)
    }

    override fun onResume() {
        super.onResume()
        surfaceView.onResume()
    }

    override fun onPause() {
        surfaceView.onPause()
        super.onPause()
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    external fun stringFromJNI(): String

    companion object {

        // Used to load the 'native-lib' library on application startup.
        init {
            System.loadLibrary("native-lib")
        }
    }
}
